<template>
    <div class="header-container">
        <div class="l-content">
            <el-button @click="headerMenu" icon="el-icon-menu" size="mini"></el-button>
            <!-- 面包屑 -->
            <el-breadcrumb separator="/">
                <el-breadcrumb-item class="myColor" v-for="item in menuData" :key="item.name">{{
                    item.label }}</el-breadcrumb-item>

            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown @command="handleCommand">
                <span class="el-dropdown-link">
                    <img class="user" src="../assets/images/001.jpg" alt="">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item command="loginout">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>

</template>
<script>
    import Cookie from 'js-cookie'
    export default {
        data() {
            return {
                menuData: []
            }
        },
        methods: {
            // 修改菜单的展开与折叠
            headerMenu() {
                this.$store.commit("collapseMenu")
            },
            // 面包屑数据
            getMenuData() {
                this.menuData = this.$store.state.tab.tabsList
            },
            // 退出登录，删除token
            handleCommand(command) {
                if (command === 'loginout') {
                    // 清除token
                    Cookie.remove('token')
                    this.$router.push('/login')
                }

            }


        },
        mounted() {
            this.getMenuData()
        },

    }
</script>

<style lang="less" scoped>
    .header-container {
        padding: 0 20px;
        background-color: #333;
        height: 60px;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .myColor /deep/ .el-breadcrumb__inner {
            color: #fff;

            font-weight: 100;
            margin-left: 10px;
        }


        .r-content {
            .user {
                width: 40px;
                height: 40px;
                border-radius: 50%;
            }
        }

        .l-content {
            display: flex;
            align-items: center;
        }
    }
</style>